package com.gzdh.tang.modu.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.gzdh.tang.modu.entity.TangReportTime;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.Map;

public interface TangReportTimeMapper extends BaseMapper<TangReportTime> {

    @Update(" update tang_order set pay_state=0 where  pay_channel=1 and create_time>#{startTime} and  create_time<#{endTime}   and pay_state=2  ")
    int updateReportFo(@Param("startTime") String startTime, @Param("endTime") String endTime);


    @Select("select count(*) as count from tang_order where pay_channel=1 and pay_state=0    and create_time>#{startTime} and  create_time<#{endTime} ")
    int countReportState(@Param("startTime") String startTime, @Param("endTime") String endTime);

    @Select("select count(*) as count from tang_order where pay_state=1 and notice_reserve=0  and create_time>#{startTime} and  create_time<#{endTime} ")
    int countReportState2(@Param("startTime") String startTime, @Param("endTime") String endTime);


    @Select("select COUNT(*) as counts,ISNULL(SUM(amount_price),0) as price   from tang_order where pay_channel=1 and pay_state=1 and " +
            "create_time>#{startTime} and  create_time<#{endTime} ")
    Map<String, Object> sumWeixinReport(@Param("startTime") String startTime, @Param("endTime") String endTime);

    @Select("select COUNT(*) as counts,ISNULL(SUM(amount_price),0) as price   from tang_order where pay_channel=3 and pay_state=1 and " +
            "create_time>#{startTime} and  create_time<#{endTime} ")
    Map<String, Object> sumAliReport(@Param("startTime") String startTime, @Param("endTime") String endTime);
}
